package com.kjlink.widget.monitoring.util;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serializable;
import java.util.UUID;

/**
 * 描述:
 *   自定义UUID生成器：生成32位无连字符的UUID
 * @author Vic.xu
 * @since 2025-08-12 10:39
 */
public class CustomUUIDGenerator implements IdentifierGenerator {

    @Override
    public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
        // 直接生成UUID并去除连字符，返回32位字符串
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}